﻿using System;
using HiTeachers.Data.Manager;
using HiTeachers.Entities;
using HiTeachers.Interfaces;
using HiTeachers.Utilities;
using NHibernate;

namespace HiTeachers.Data
{
    public class PaymentInfoDao : AbstractNHibernateDao<PaymentInfo, Guid>, IPaymentInfoDao
    {
        public PaymentInfo GetByOrderCode(string orderCode)
        {
            try
            {
                string hsql = "from PaymentInfo pif where pif.OrderCode = :orderCode";

                IQuery query = NHibernateSession.CreateQuery(hsql);
                query.SetString("orderCode", orderCode);

                return query.UniqueResult<PaymentInfo>();
            }
            catch (Exception ex)
            {
                Logger.Debug(ex.Message);
                return null;
            }
        }
    }
}
